package com.aop.demo;


import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
//切面类
@Aspect
public class XmlAdvice {
    //配置连接点
    @Pointcut("execution(* com.aop.demo.*.add*(..))||execution(* com.aop.demo.*.select*(..))")
    public void pointCut01() {
    }

    @Pointcut("execution(* com.aop.demo.*.delete*(..))||execution(* com.aop.demo.*.update*(..))")
    public void pointCut02() {

    }

    //后置通知
    @After("execution(* com.aop.demo.*.delete*(..))")
    public void after() {
        System.out.println("后置通知********");
    }

    //环绕通知
    @Around("execution(* com.aop.demo.*.add*(..))")
    public Object around(ProceedingJoinPoint pjp) throws Throwable {
        System.out.println("环绕通知前********");
        Object proceed = pjp.proceed();
        System.out.println("环绕通知后********");
        return proceed;
    }
    //前置通知
    @Before("execution(* com.aop.demo.*.update*(..))")
    public void before() {
        System.out.println("前置通知********");
    }
    //异常通知
    @AfterThrowing("execution(* com.aop.demo.*.*(..))")
    public void afterThrowing() {
        System.out.println("异常通知********");
    }
    //最终通知
    @AfterReturning("execution(* com.aop.demo.*.select*(..))")
    public void afterReturning() {
        System.out.println("最终通知********");
    }
}
